package com.gator.rabbitmq.pablo_rabbitmq.boot.rabbitmq.awesome.consumer;

import com.gator.rabbitmq.pablo_rabbitmq.boot.rabbitmq.config.PublishConfirmConfig;
import com.rabbitmq.client.Channel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @Author PABLO
 * @Date 2022/6/6 18:39
 * @Desc
 */
@Component
@Slf4j
public class PublishMsgAckByExchangeConsumer {

    @RabbitListener(queues = PublishConfirmConfig.CONFIRM_QUEUE_NAME)
    public void receive(Message message, Channel channel) {
        String msg = new String(message.getBody());
        log.info("收到confirm队列消息-->当前时间:{}-->confirmQueueReceiveInfo-->{}", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()), msg);
    }
}
